<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<!--#include file="includes/common.aspx"-->
<!--#include file="includes/includeitems.aspx"-->
<!--#include file="includes/getValue.aspx"-->
<script runat="server">
Dim continue="",strItems="",contacttime=""
Dim custid="",fullname="",address="",city=""
Dim tel="",fax="",contact="",province=""
Dim Amount=0
Dim ItemName=""
Dim AuthorName=""
Dim Quantity=0
Dim SalesPrice=0
Dim ItemStyle=""	
Dim ItemID=""
Dim ProName=""
Dim ListPrice=0
Dim SalesDiscount=0
Dim Weight=0
Dim shipcost=0
Dim Available=""
Dim Discount=0,Total=0,No=0 			
Sub Page_Load(ByVal sender As Object, _
	ByVal e As EventArgs)	
	Dim strSQL as String=""
	continue="id="&request.querystring("id")
	continue= "&rows="&request.querystring("rows")
	continue +=  "&pages="&request.querystring("pages")
	continue +=  "&page="&request.querystring("page")
	continue +=  "&sort="&request.querystring("sort")
	continue +=  "&from_="&request.querystring("from_")
     if session("shoppingcarts")="" then
	response.redirect("expiry.aspx?" & continue)
     else
	session("shoppingcarts")=session("shoppingcarts")
	session("shoppingcart")=session("shoppingcart")
	session("custinfo")=session("custinfo")
    End if
	if request.form("rdcusttype")="old" then				  
		 strSQL ="select * from tblcustomers"
		 strSQL = strSQL & " where username='"
		 strSQL =strSQL & replace(request.form("txtemail"),"'","''")
		 strSQL =strSQL & "' and password='"
		 strSQL =strSQL & replace(request.form("txtpwd"),"'","''") & "'"
 		Dim myReader As SqlDataReader 
		Dim myConn As SqlConnection
		Dim strConn=ConfigurationSettings.appSettings("conn")
		myConn  = New SqlConnection(strConn)
		myConn.Open		
		Dim myCom As SqlCommand = _
		New SqlCommand(strSQL,myConn)
		myReader = myCom.ExecuteReader()
		if myReader.Read() Then
		    custid=myReader("CustID").toString()
		    fullname=myReader("CustName")
		    address=myReader("Address")
		    tel=myReader("Tel")
		    fax=myReader("FaxNo")
		    contact=myReader("ContactPerson")
		    contacttime=myReader("ContactTime")
		    city=myReader("City")
		    province=myReader("ProvinceID")
		else
		    response.redirect("preorder.aspx?errors=old")
		end if
		myReader.Close
		myConn.Close
	else
		if request.form("rdcust")="Yes" then
			strSQL="select count(*) as No from "
			strSQL=strSQL &" tblCustomers where "
			strSQL=strSQL & "UserName='" 
			strSQL=strSQL & request.form("txtemail") & "'"	
			if ReturnNo(strSQL)> 0 then
			  response.redirect("preorder.aspx?errors=new")
			end if
		End If
	end if
End Sub
</script>
<HTML><HEAD><TITLE>InterShop-Online Shopping</TITLE>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<META content=""  name=description>
<META content="trading software platform" name=keywords>
<META http-equiv=Pragma content=no-cache>
<LINK href="style.css" type=text/css rel=stylesheet>
<SCRIPT language=JavaScript>
        	self.defaultStatus = "Online-Shopping!";                           
</SCRIPT>
</HEAD>
<BODY bottomMargin=0 leftMargin=0 topMargin=0  rightMargin=0 marginheight="0"  marginwidth="0">
<!--#include file="top.aspx"-->
<TABLE cellSpacing=0 cellPadding=0 border=0  width="775" >
  <TBODY> 
  <TR>
    <TD vAlign=top align="center" width="160"> 
      <table width="18%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td align="center"><br> 
            <table border=0 cellspacing=0 cellpadding=0>
              <tr valign=bottom align=center> 
                <td><img src="images/new-products.gif" height="19" width="155"></td>
              </tr>
              <tr valign=top align=center> 
                <td> 
                  <table border=0 width=155 cellpadding=1 cellspacing=0 bgcolor=#708090 >
                    <tr> 
                      <td width=100% height="49"> 
                        <table width=100% border=0 cellpadding=4 cellspacing=0 bgcolor=#FFFFFF>
                          <tr> 
                            <td valign=top width=8% align="left" height="51" bgcolor="#EEEECC"> 
                              <table cellspacing=0 cellpadding=0 border=0  width="100%">
                                <tr> 
                                  <td colspan=2>&nbsp;</td>
                                </tr>
                                <tbody> 
                                <tr  align="left"> 
                                  <td colspan=2> 
                                    <input size=15  onFocus="this.value = '';" value="Keyword" name=txtKeyword class=textbox>
                                  </td>
                                </tr>
                                <tr> 
                                  <td align=left> 
                                    <select name="cbCate">
                                      <option selected>All Products</option>
                                      <option>Books</option>
                                      <option>Poems</option>
                                    </select>
                                    <img height=21 
            alt="Click here to search the Item." 
            src="images/go.gif" 
            width=21 align=absMiddle 
      border=0></td>
                                </tr>
                                </tbody> 
                              </table>
                            </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
            </table>
      </table>
	  <table width="18%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td align="center"><br> 
            <table border=0 cellspacing=0 cellpadding=0>
              <tr valign=bottom align=center> 
                <td><img src="images/new-products.gif" height="19" width="155"></td>
              </tr>
              <tr valign=top align=center> 
                <td> 
                  <table border=0 width=155 cellpadding=1 cellspacing=0 bgcolor=#708090 >
                    <tr> 
                      <td width=100% > 
                        <table width=100% border=0 cellpadding=4 cellspacing=0 bgcolor=#FFFFFF>
                          <tr> 
                            <td valign=top width=8% align="left" bgcolor="#CAE2F0"> 
                              <input size=15  onFocus="this.value = '';" value="Keyword" name=txtKeyword2 class=textbox>
                              <img height=21 
            alt="Click here to search the Item." 
            src="images/go-button.gif" 
            width=21 align=absMiddle 
      border=0> <br>
                              <img src="images/powered-by-google.gif" width="95" height="14"> 
                            </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
            </table>
      </table>
       <table width="18%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td align="center"><br> 
            <table border=0 cellspacing=0 cellpadding=0>
              <tr valign=bottom align=center> 
                <td><img src="images/browse-items.gif" width="155" height="19"></td>
              </tr>
              <tr valign=top align=center> 
                <td> 
                  <table border=0 width=155 cellpadding=1 cellspacing=0 bgcolor=#708090 >
                    <tr> 
                      <td width=100% height="49"> 
                        <table width=100% border=0 cellpadding=4 cellspacing=0 bgcolor=#FFFFFF>
                          <tr> 
                            <td valign=top width=8% align="left" height="51" bgcolor="#CAE2F0">
							 <!--#include file="includes/listsubcategories.htm"-->
                            </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
            </table>
      </table>
      <!--#include file="left.aspx"-->
    </TD>
    <TD class=margin width="1" valign="top" align="right" bgcolor="#666666" > 
    </TD>
    <TD class=text_normal id=mainContent vAlign=top width="420"> 
      <TABLE cellSpacing=4 cellPadding=4 width="100%" align=left border=0 height="61">
        <TR> 
          <TD vAlign=top align=left height="46"> 
            <!--#include file="submenu.aspx"--><br>
	<img src="images/orders.gif">
             </TD>
        </TR>
        <TBODY> 
        <TR> 
          <TD vAlign=top align=middle>
	<form action="doorders.aspx?<%=continue%>" method="post" name="frmOrder">
                    <table width="400" border="0" cellspacing="0" cellpadding="0" >
                      <tr> 
                        <td align="middle" valign="top" > 
                          <table width="100%" border="0" cellspacing="1" cellpadding="1">
                            <tr> 
                              <td  valign="top"> 
                                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                  <%
		       if request.form("rdcusttype")="new" then
			province=request.form("cbProvinces")
			%>
                                  <tr> 
                                    <td width="20%" nowrap> <font face="Arial">Email 
                                      address</font> </td>
                                    <td width="80%"><b><font face="Arial"> :
                                      <%=request.form("txtemail")%>
                                      </font></b> 
                                      <input name="txtemail" type="hidden" 
						value="<%=request.form("txtemail")%>">
                                      <br>
                                    </td>
                                  </tr>
                                  <tr> 
                                    <td width="100%" colspan=2> I want to become 
                                      our customer: 
                                      <%=request.form("rdcust")%>
                                      <input name="rdcust" type="hidden" 
						value="<%=request.form("rdcust")%>">
                                      <input name="txtpwd" type="hidden"  
						value="<%=request.form("txtpwd")%>">
                                    </td>
                                  </tr>
                                  <tr> 
                                    <td width="20%"><font face="Arial"> Full Name</font></td>
                                    <td width="80%"> <font face="Arial"> :
                                      <%=request.form("txtfullname")%>
                                      <input name="txtfullname" type="hidden"
						 value="<%=request.form("txtfullname")%>">
                                      </font></td>
                                  </tr>
                                  <tr> 
                                    <td width="20%"><font face="Arial"> Address</font></td>
                                    <td width="80%"> <font face="Arial"> :
                                      <%=request.form("txtaddress")%>
                                      <input name="txtaddress" type="hidden" 
						value="<%=request.form("txtaddress")%>">
                                      </font></td>
                                  </tr>
                                  <tr> 
                                    <td width="20%"><font face="Arial"> Telephone</font></td>
                                    <td width="80%"> <font face="Arial"> :
                                      <%=request.form("txttel")%>
                                      <input name="txttel" type="hidden" 
						value="<%=request.form("txttel")%>">
                                      </font></td>
                                  </tr>
                                  <tr> 
                                    <td width="20%"><font face="Arial"> Fax No</font></td>
                                    <td width="80%"> <font face="Arial"> :
                                      <%=request.form("txtfax")%>
                                      <input name="txtfax" type="hidden" 
						value="<%=request.form("txtfax")%>">
                                      </font></td>
                                  </tr>
                                  <tr> 
                                    <td width="20%"><font face="Arial"> Contact 
                                      Person</font></td>
                                    <td width="80%"> <font face="Arial"> :
                                      <%=request.form("txtcontact")%>
                                      <input name="txtcontact" type="hidden" 
						value="<%=request.form("txtcontact")%>">
                                      </font></td>
                                  </tr>
		      <tr> <td>
                                    Time</font></td>
                                    <td width="80%"> <font face="Arial"> :
                                      <%=request.form("txtcontacttime")%>
                                      <input name="txtcontacttime" type="hidden" 
						value="<%=request.form("txtcontacttime")%>">
                                      </font></td>
                                  </tr>
		       <tr> 
                                    <td width="20%"><font face="Arial"> City
                                    </font></td>
                                    <td width="80%"> <font face="Arial"> :
                                      <%=request.form("txtcity")%>
                                      <input name="txtcity" type="hidden" 
						value="<%=request.form("txtcity")%>">
                                      </font></td>
                                  </tr>
                                  <tr> 
                                    <td width="20%"><font face="Arial"> Province</font></td>
                                    <td width="80%"> <font face="Arial"> :
                                      <%= getValue("select ProvinceName as Name from tblProvinces where ProvinceID='" & province & "'")%>
                                      <input type=hidden name=custtype 
								value="new">
                                      <input type=hidden name="rdcusttype" 
								value="new">
                                      <input type=hidden name=txtprovince 
						value="<%=province%>"></font>
                                    </td>
                                  </tr>
                                  <%
			else
		     %>
                                  <tr> 
                                    <td width="20%" nowrap><font face="Arial"> 
                                      Email address</font> </td>
                                    <td width="80%"><b> <font face="Arial"> :
                                      <%=request.form("txtemail")%>
			<input type=hidden name=txtid
						value="<%=custid%>">
			<input name="txtfullname" type="hidden"
						 value="<%=fullname%>">
			<input name="txtemail" type="hidden"
						 value="<%=request.form("txtemail")%>">
			<input name="txtaddress" type="hidden"
						 value="<%=address%>">
			<input name="txttel" type="hidden"
						 value="<%=tel%>">
			<input name="txtfax" type="hidden"
						 value="<%=fax%>">
                                      </font></b><br>
                                    </td>
                                  </tr>
                                  <tr> 
                                    <td width="20%"><font face="Arial"> Fullame</font></td>
                                    <td width="80%"> <font face="Arial"> :
                                      <%=fullname%>
                                      </font></td>
                                  </tr>
                                  <tr> 
                                    <td width="20%"><font face="Arial"> Address</font></td>
                                    <td width="80%"> <font face="Arial"> :
                                      <%=address%>
                                      </font></td>
                                  </tr>
                                  <tr> 
                                    <td width="20%"><font face="Arial"> Telephone</font></td>
                                    <td width="80%"> <font face="Arial"> :
                                      <%=tel%>
                                      </font></td>
                                  </tr>
                                  <%
		    if(fax<>"") then
			%>
                                  <tr> 
                                    <td width="20%"><font face="Arial"> Fax No</font></td>
                                    <td width="80%"> <font face="Arial"> :
                                      <%=fax%>
                                      </font></td>
                                  </tr>
                                  <%
		end if
		 if(city<>"") then
			%>
                                  <tr> 
                                    <td width="20%"><font face="Arial"> City</font></td>
                                    <td width="80%"> <font face="Arial"> :
                                      <%=city%>
                                      </font></td>
                                  </tr>
                                  <%
		end if
		if(contact<>"") then
			%>
                                  <tr> 
                                    <td width="20%"><font face="Arial"> Contact 
                                      Person</font></td>
                                    <td width="80%"> <font face="Arial"> :
                                      <%=contact%>
                                      </font></td>
                                  </tr>
                                  <%
			end if
			if(contacttime<>"") then
			%>
                                  <tr> 
                                    <td width="20%"><font face="Arial"> Contact Time</font></td>
                                    <td width="80%"> <font face="Arial"> :
                                      <%=contacttime%>
                                      </font></td>
                                  </tr>
                                  <%
			end if%>
                                  <tr> 
                                    <td width="20%"><font face="Arial"> Province</font></td>
                                    <td width="80%"> <font face="Arial"> :
                                      <%= getValue("select ProvinceName as Name from tblProvinces where ProvinceID='" & province & "'")%>
                                      <input type=hidden 
						name="rdcusttype" value="old">
                                      <input type=hidden name="custid" 
						value="<%=custid%>"></font>
                                    </td>
                                  </tr>
                                  <%
			end if
				%>
                                  <tr> 
                                    <td width="20%" valign=top> <font face="Arial">Shippment 
                                      </font></td>
                                    <td width="80%"> <font face="Arial"> 
                                      <input name="rdship" type="radio" 
						value="1">
                                      Normal(1-2 days) 
                                      <input type="radio" name="rdship" 
						value="2"  checked>
                                      Medium(3-4 days) <br>
                                      <input type="radio" name="rdship" 
						value="3">
                                      Fast(5-10 days)</font>
			<input type="radio" name="rdship" 
						value="4">
                                      Fast(10-15 days)</font><br>
                                    </td>
                                  </tr>
                                  <tr> 
                                    <td width="20%" valign=top> <font face="Arial">Payment 
                                      </font></td>
                                    <td width="80%"> <font face="Arial"> 
                                      <input name="rdpay" type="radio" 
						value="CAS" checked>
                                      Cash 
                                      <input type="radio" name="rdpay" 
						value="TRA">
                                      Bank Tranfer <br>
                                      <input type="radio" name="rdpay" 
						value="SHO">
                                      InterShop Cards		         
			<input type="radio" name="rdpay" 
						value="WRL">
                                      Credit Card via World Pay</font>
			<br><br>
                                    </td>
                                  </tr>
                                  <tr> 
                                    <td colspan=2> 
                                      <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                        <tr valign="center"> 
                                          <td width="5%" height="14" align="middle"><font face="Arial" color="#ff6600">No</font></td>
                                          <td width="30%" height="14"><font face="Arial" color="#ff6600">Item 
                                            Name</font></td>
                                          <td width="9%" height="14"><font face="Arial" color="#ff6600"> 
                                            Quantity</font></td>
                                          <td width="10%" height="14" align=right><font face="Arial" color="#ff6600">List Price</font></td>
			<td width="10%" height="14" align=right><font face="Arial" color="#ff6600">Discount</font></td>
                                          <td width="12%" height="14" align=right><font face="Arial" color="#ff6600">Sales Price</font></td>
                                          <td width="10%" height="14" align=right><font face="Arial" color="#ff6600">Amount</font></td>
                                        </tr>
                                        <tr valign="top"> 
                                          <td colspan="7" align="middle"> 
                                            <hr noshade size="1">
                                          </td>
                                        </tr>
                                        <%
			 if session("shoppingcart")>0 then					
			for No = 1 to session("shoppingcart")				 	 					   					  
				ItemName=Seperate(session("shoppingcarts"),"itemname" & No) 
				AuthorName=Seperate(session("shoppingcarts"),"itemauthorname" & No) 
				Quantity=Seperate(session("shoppingcarts"),"itemqtty" & No)
				Weight= Weight+Seperate(session("shoppingcarts"),"itemweight" & No)
				ListPrice=Seperate(session("shoppingcarts"),"itemlistprice" & No)  	
				SalesPrice=Seperate(session("shoppingcarts"),"itemprice" & No)  	
				Discount=discount+Seperate(session("shoppingcarts"),"itemdiscount" & No) 
				ItemStyle=Seperate(session("shoppingcarts"),"itemstyle" & No)
				Amount=Amount+ Quantity* SalesPrice
			%>
			<tr>
			<td valign=top><%=No%></td>
			<td  valign=top><%=ItemName%></td>
			<td  valign=top align=center><%=Quantity%></td>
			<td  valign=top align=right><%=ListPrice%></td>
			<td  valign=top align=right><%=Discount%></td>
			<td  valign=top align=right><%=SalesPrice%></td>
			<td  valign=top align=right><%=Quantity*SalesPrice%></td>
			</tr>
			<%		  		  		  		  
			next				
		      else
			response.write("<tr><td colspan=6><font color=red><b>Gio hang cua ban dang rong.<b></font></td></tr>")
		      end if		
		      shipcost=ReturnNo("select Cost as No from tblShipCost Where ProvinceID='" & province & "' and " & weight & " > WeightFrom and " & weight & " <=WeightTo")
			%>
                                      </table>
                                    </td>
                                  </tr>
                                  <tr valign="top"> 
                                    <td colspan="7" align="middle"> 
                                      <hr noshade size="1">
                                    </td>
                                  </tr>
                                  <tr> 
                                    <td colspan=2> 
                                      <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                        <tr valign="center"> 
                                          <td height="14">&nbsp;</td>
                                          <td >&nbsp;</td>
                                          <td height="14">&nbsp;</td>
                                          <td  height="14">&nbsp;</td>
                                          <td height="14" align=left>Amount</td>
                                          <td height="14" align=right><font face="Arial" color="#ff6600"> 
                                            <%=formatnumber(Amount,2)%>
                                            </font></td>
                                        </tr>
		           <tr valign="center"> 
                                          <td height="14">&nbsp;</td>
                                          <td >&nbsp;</td>
                                          <td height="14">&nbsp;</td>
                                          <td  height="14">&nbsp;</td>
                                          <td height="14" align=left>Discount Amount</td>
                                          <td height="14" align=right><font face="Arial" color="#ff6600"> 
                                            <%=formatnumber(Discount,2)%>
                                            </font></td>
                                        </tr>
                                        <tr valign="center"> 
                                          <td height="14">&nbsp;</td>
                                          <td valign=top> 
                                            <input type="submit" name="Submit" value="Agree" class=button>
                                            <input type="button" name="Back" value="Back" class=button>
                                            <input type=hidden name=txtamount  value="<%=Amount%>">
                                            <input type=hidden name=txtshipcost value="<%=shipcost%>">
			  <input type=hidden name=txtdiscount value="<%=Discount%>">
                                          </td>
                                          <td  height="14">&nbsp;</td>
                                          <td  height="14">&nbsp;</td>
                                          <td  height="14" align=left>ShipCost</td>
                                          <td height="14" align=right><font face="Arial" color="#ff6600">
                                            <%=formatnumber(shipcost,2)%>
                                            </font></td>
                                        </tr>
                                        <tr valign="center"> 
                                          <td  height="14">&nbsp;</td>
                                          <td >&nbsp;</td>
                                          <td    height="14">&nbsp;</td>
                                          <td  height="14">&nbsp;</td>
                                          <td   height="14" align=left>Total</td>
                                          <td   height="14" align=right><font face="Arial" color="#ff6600">
                                            <%=formatnumber(Amount+shipcost,2)%>
                                            </font></td>
                                        </tr>
                                      </table>
                                    </td>
                                  </tr>
                                </table>
                              </td>
                            </tr>
                          </table>
                        </td>
                      </tr>
                    </table>
                  </form>
	</TD>
        </TR>
        </TBODY> 
      </TABLE>
    </TD>
    <TD class=margin width="1" valign="top" align="right" bgcolor="#666666" > 
    </TD>
    <TD class=margin valign="top" align="left" width="160"> 
      <TABLE>
        
        <tr> 
          <td>&nbsp;</td>
          <td valign=top> 
            <!--#include file="includes/right-next.htm" -->
          </td>
        </tr>
        <tr> 
          <td>&nbsp;</td>
          <td valign="top"><br>
            <table width="18%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td align="center"> 
                  <table border=0 cellspacing=0 cellpadding=0>
                    <tr valign=bottom align=center> 
                      <td><img src="images/new-products.gif" width="155" height="19"></td>
                    </tr>
                    <tr valign=top align=center> 
                      <td> 
                        <table border=0 width=155 cellpadding=1 cellspacing=0 bgcolor=#708090 >
                          <tr> 
                            <td width=100%> 
                              <table width=100% border=0 cellpadding=4 cellspacing=0 bgcolor=#FFFFFF>
                                <tr> 
                                  <td valign=top width=8% align="left" height="52"> 
                                    <p>&nbsp;</p>
                                  </td>
                                  <td valign=top width=92% align="left" height="52"> 
                                    <!--#include file="includes/right-top.htm" -->
                                  </td>
                                </tr>
                              </table>
                            </td>
                          </tr>
                        </table>
                  </table>
            </table>
          </td>
        </tr>
        <tr> 
          <td>&nbsp;</td>
          <td valign=top> <br>
            <table width="18%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td align="center"> 
                  <table border=0 cellspacing=0 cellpadding=0>
                    <tr valign=bottom align=center> 
                      <td><img src="images/new-products.gif" width="155" height="19"></td>
                    </tr>
                    <tr valign=top align=center> 
                      <td> 
                        <table border=0 width=155 cellpadding=1 cellspacing=0 bgcolor=#708090 >
                          <tr> 
                            <td width=100%> 
                              <table width=100% border=0 cellpadding=4 cellspacing=0 bgcolor=#FFFFFF>
                                <tr> 
                                  <td valign=top width=8% align="left" height="52"> 
                                    <p>&nbsp;</p>
                                  </td>
                                  <td valign=top width=92% align="left" height="52"> 
                                    <!--#include file="includes/right-top.htm" -->
                                  </td>
                                </tr>
                              </table>
                            </td>
                          </tr>
                        </table>
                  </table>
            </table>
          </td>
        </tr>
      </TABLE>
    </TD>
  </TR></TBODY></TABLE>
  <!--#include file="bottom.aspx"-->
</BODY></HTML>
